-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
token-cli: add command for updating metadata address #4810
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution! A few bits to firm up the interface, and also, could you add a test for this? You can use the existing metadata_pointer()
test for creating, and then just add a step where you update the metadata address, and check that the change was properly propagated.
token/cli/src/main.rs
Outdated
.arg(owner_address_arg()) | ||
.arg(multisig_signer_arg()) | ||
.nonce_args(true) | ||
.offline_args(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can remove the offline args, since the instruction doesn't support sign-only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
token/cli/src/main.rs
Outdated
Defaults to the client keypair.", | ||
), | ||
) | ||
.arg(owner_address_arg()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're using the authority
arg and not the owner
arg, so this can be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
token/cli/src/main.rs
Outdated
.validator(is_valid_signer) | ||
.takes_value(true) | ||
.help( | ||
"Specify the token's authority. \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Let's be clear
"Specify the token's authority. \ | |
"Specify the token's metadata-pointer authority. \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
token/cli/src/main.rs
Outdated
.arg( | ||
Arg::with_name("metadata_address") | ||
.long("metadata-address") | ||
.value_name("ADDRESS") | ||
.takes_value(true) | ||
.help( | ||
"Specify address that stores token metadata." | ||
), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will introduce a footgun. As it stands, if someone just accidentally forgets to put in a metadata address, the command will clear it.
Instead, this should look like the new_authority
flag in Authorize
, where someone can specify --disable
to clear the metadata pointer address. Then if --disable
is not provided, the metadata_address
argument is required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
token/cli/src/main.rs
Outdated
@@ -3624,6 +3652,44 @@ fn app<'a, 'b>( | |||
.nonce_args(true) | |||
.offline_args(), | |||
) | |||
.subcommand( | |||
SubCommand::with_name(CommandName::UpdateMetadataPointerAddress.into()) | |||
.about("Updates default account state for the mint. Requires the default account state extension.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.about("Updates default account state for the mint. Requires the default account state extension.") | |
.about("Updates metadata pointer address for the mint. Requires the metadata pointer extension.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
token/cli/src/main.rs
Outdated
.takes_value(true) | ||
.index(1) | ||
.required(true) | ||
.help("The address of the token mint to update default account state"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.help("The address of the token mint to update default account state"), | |
.help("The address of the token mint to update the metadata pointer address"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
token/cli/src/main.rs
Outdated
@@ -144,6 +144,7 @@ pub enum CommandName { | |||
EnableCpiGuard, | |||
DisableCpiGuard, | |||
UpdateDefaultAccountState, | |||
UpdateMetadataPointerAddress, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit for ease of use
UpdateMetadataPointerAddress, | |
UpdateMetadataAddress, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're almost there! When you add the disable flag, can you add one more step to the test to disable the metadata pointer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last bit then this should be good to go!
) | ||
.arg( | ||
Arg::with_name("metadata_address") | ||
.index(2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add .validator(is_valid_pubkey)
for this arg too? Otherwise, if someone inputs an invalid pubkey, it'll disable the metadata pointer address!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yupp, Done! and also sorry about this many commits. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks for your patience! I'll ping you if CI has any issues.
And a lot of commits is really good, it makes it much easier for me to review. Do avoid merge commits in the future though, and prefer rebasing + force-pushing your branch whenever you need to.
All good, thanks for your work! |
resolved #4701